        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>CircleShape class / box2d Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d" data-type="CircleShape">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d.html">box2d</a> &rsaquo; <a href="../box2d/CircleShape.html">CircleShape</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>CircleShape</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<pre class="source">
class CircleShape extends Shape {
 /**
  * The current position of the center of this circle.
  */
 final vec2 position;

 /**
  * A constructor for internal use only. Instead use Body.createShape with a
  * CircleDef.
  */
 CircleShape() :
   super(ShapeType.CIRCLE, 0),
   position = new vec2.zero() {
 }

 /**
  * Constructs a new CircleShape equal to the given CircleShape.
  */
 CircleShape.copy(CircleShape other) :
   super(other.type, other.radius),
   position = new vec2.copy(other.position) { }


 /**
  * Returns true if the point is contained in the given shape when the given
  * rotation transform is applied. Implements superclass abstract method of
  * the same name.
  */
 bool testPoint(Transform transform, vec2 point) {
   vec2 center = new vec2.copy(position);
   transform.rotation.transform(center);
   center.add(transform.position);

   vec2 d = center.sub(point).negate();
   return dot(d, d) &lt;= radius * radius;
 }

 /**
  * Compute the axis aligned box for this Shape when the given transform is
  * applied. Stores the result in the given box.
  */
 void computeAxisAlignedBox(AxisAlignedBox argBox, Transform argTransform) {
   vec2 p = new vec2.copy(position);
   argTransform.rotation.transform(p);
   p.add(argTransform.position);

   argBox.lowerBound.setComponents(p.x - radius, p.y - radius);
   argBox.upperBound.setComponents(p.x + radius, p.y + radius);
 }

 /** Returns a clone of this circle. */
 Shape clone() =&gt; new CircleShape.copy(this);

 /**
  * Computes the mass properties of this Circle at the given density and stores
  * the result in the given MassData object.
  */
 void computeMass(MassData massData, num density) {
   massData.mass = density * math.PI * radius * radius;
   massData.center.copyFrom(position);

   // Store inertia above the local origin.
   massData.inertia = massData.mass * (.5 * radius * radius +
       dot(position, position));
 }
}
</pre>
</div>
<h3>Extends</h3>
<p>
<span class="type-box"><span class="icon-class"></span><a href="../box2d/Shape.html">Shape</a></span>&nbsp;&gt;&nbsp;<span class="type-box"><span class="icon-class"></span><strong>CircleShape</strong></span></p>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="CircleShape">
<button class="show-code">Code</button>
new <strong>CircleShape</strong>() <a class="anchor-link" href="#CircleShape"
              title="Permalink to CircleShape.CircleShape">#</a></h4>
<div class="doc">
<p>A constructor for internal use only. Instead use Body.createShape with a
CircleDef.</p>
<pre class="source">
CircleShape() :
 super(ShapeType.CIRCLE, 0),
 position = new vec2.zero() {
}
</pre>
</div>
</div>
<div class="method"><h4 id="CircleShape.copy">
<button class="show-code">Code</button>
new <strong>CircleShape.copy</strong>(<a href="../box2d/CircleShape.html">CircleShape</a> other) <a class="anchor-link" href="#CircleShape.copy"
              title="Permalink to CircleShape.CircleShape.copy">#</a></h4>
<div class="doc">
<p>Constructs a new CircleShape equal to the given CircleShape.</p>
<pre class="source">
CircleShape.copy(CircleShape other) :
 super(other.type, other.radius),
 position = new vec2.copy(other.position) { }
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="position">
<button class="show-code">Code</button>
final <a href="../vector_math/vec2.html">vec2</a>         <strong>position</strong> <a class="anchor-link"
            href="#position"
            title="Permalink to CircleShape.position">#</a>
        </h4>
        <div class="doc">
<pre class="source">
position
</pre>
</div>
</div>
<div class="field inherited"><h4 id="radius">
<button class="show-code">Code</button>
num         <strong>radius</strong> <a class="anchor-link"
            href="#radius"
            title="Permalink to CircleShape.radius">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d/Shape.html">Shape</a> </div><div class="doc">
<pre class="source">
radius
</pre>
</div>
</div>
<div class="field inherited"><h4 id="type">
<button class="show-code">Code</button>
int         <strong>type</strong> <a class="anchor-link"
            href="#type"
            title="Permalink to CircleShape.type">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d/Shape.html">Shape</a> </div><div class="doc">
<pre class="source">
type
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="clone">
<button class="show-code">Code</button>
<a href="../box2d/Shape.html">Shape</a> <strong>clone</strong>() <a class="anchor-link" href="#clone"
              title="Permalink to CircleShape.clone">#</a></h4>
<div class="doc">
<p>Returns a clone of this circle. </p>
<pre class="source">
Shape clone() =&gt; new CircleShape.copy(this);
</pre>
</div>
</div>
<div class="method"><h4 id="computeAxisAlignedBox">
<button class="show-code">Code</button>
void <strong>computeAxisAlignedBox</strong>(<a href="../box2d/AxisAlignedBox.html">AxisAlignedBox</a> argBox, <a href="../box2d/Transform.html">Transform</a> argTransform) <a class="anchor-link" href="#computeAxisAlignedBox"
              title="Permalink to CircleShape.computeAxisAlignedBox">#</a></h4>
<div class="doc">
<p>Compute the axis aligned box for this Shape when the given transform is
applied. Stores the result in the given box.</p>
<pre class="source">
void computeAxisAlignedBox(AxisAlignedBox argBox, Transform argTransform) {
 vec2 p = new vec2.copy(position);
 argTransform.rotation.transform(p);
 p.add(argTransform.position);

 argBox.lowerBound.setComponents(p.x - radius, p.y - radius);
 argBox.upperBound.setComponents(p.x + radius, p.y + radius);
}
</pre>
</div>
</div>
<div class="method"><h4 id="computeMass">
<button class="show-code">Code</button>
void <strong>computeMass</strong>(<a href="../box2d/MassData.html">MassData</a> massData, num density) <a class="anchor-link" href="#computeMass"
              title="Permalink to CircleShape.computeMass">#</a></h4>
<div class="doc">
<p>Computes the mass properties of this Circle at the given density and stores
the result in the given MassData object.</p>
<pre class="source">
void computeMass(MassData massData, num density) {
 massData.mass = density * math.PI * radius * radius;
 massData.center.copyFrom(position);

 // Store inertia above the local origin.
 massData.inertia = massData.mass * (.5 * radius * radius +
     dot(position, position));
}
</pre>
</div>
</div>
<div class="method"><h4 id="testPoint">
<button class="show-code">Code</button>
bool <strong>testPoint</strong>(<a href="../box2d/Transform.html">Transform</a> transform, <a href="../vector_math/vec2.html">vec2</a> point) <a class="anchor-link" href="#testPoint"
              title="Permalink to CircleShape.testPoint">#</a></h4>
<div class="doc">
<p>Returns true if the point is contained in the given shape when the given
rotation transform is applied. Implements superclass abstract method of
the same name.</p>
<pre class="source">
bool testPoint(Transform transform, vec2 point) {
 vec2 center = new vec2.copy(position);
 transform.rotation.transform(center);
 center.add(transform.position);

 vec2 d = center.sub(point).negate();
 return dot(d, d) &lt;= radius * radius;
}
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
